yjx.directive('containerScrollTop',['$rootScope','ipCookie','$timeout',function($rootScope,ipCookie,$timeout){
/*缓存主页 产品中心 获得支持三个页面的滚动条*/
    return {
        restrict: "EAC",
        scope: false,
        link: function ($scope, $element, attr) {//滚轮记录 一个当前，一个历史
            if(ipCookie('ScrollHome') && ipCookie('ScrollHome').scrollTop ) {
                $rootScope._ScrollHome = ipCookie('ScrollHome').scrollTop
            }
            if(ipCookie('ScrollProduct') && ipCookie('ScrollProduct').scrollTop ) {
                $rootScope._ScrollProduct = ipCookie('ScrollProduct').scrollTop
            }
            if(ipCookie('ScrollSupport') && ipCookie('ScrollSupport').scrollTop ) {
                $rootScope._ScrollSupport = ipCookie('ScrollSupport').scrollTop
            }

            if($element.hasClass('m-home')   ){
                console.log($rootScope._ScrollHome)
                $timeout(function(){
                    $element.context.scrollTop = $rootScope._ScrollHome?$rootScope._ScrollHome:0 ;
                },100)
            }
            if($element.children().hasClass('m-product') ){
                $timeout(function(){
                    $element[0].scrollTop =  $rootScope._ScrollProduct?$rootScope._ScrollProduct:0;
                },100)
            }
            if($element.hasClass('m-support') ){
                console.log($rootScope._ScrollSupport)
                $timeout(function(){
                    $element.context.scrollTop =  $rootScope._ScrollSupport?$rootScope._ScrollProduct:0;
                },100)
            }

            $element.bind('‘、', function () {
                $timeout(function () {
                    if($rootScope.tabCtrlName == $rootScope.tabCtrlNameArr[0]){
                        //console.log($element.context.scrollTop)
                        ipCookie('ScrollHome', {'scrollTop': $element.context.scrollTop},{domain: DOMAIN, path: PATH});
                    }
                    else if($rootScope.tabCtrlName == $rootScope.tabCtrlNameArr[1]){
                        ipCookie('ScrollProduct', {'scrollTop': $element.context.scrollTop},{domain: DOMAIN, path: PATH});
                    }
                    else if($rootScope.tabCtrlName == $rootScope.tabCtrlNameArr[2]){
                        ipCookie('ScrollSupport', {'scrollTop': $element.context.scrollTop},{domain: DOMAIN, path: PATH});
                    }
                })
            });
        }
    }
}])